package com.sky.controller.admin;


import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.*;

/**
 * 商铺管理
 */
@RestController("adminShopController")
@RequestMapping("/admin/shop")
@Slf4j
@Api(tags = "商铺相关接口")
public class ShopController {


    @Autowired
    RedisTemplate redisTemplate;
    /**
     * 设置店铺状态
     */
    @PutMapping("/{status}")
    @ApiOperation(value = "设置店铺状态")
    public Result setStatus(@PathVariable Integer status)
    {
        redisTemplate.opsForValue().set("SHOP_STATUS",status);
        return Result.success();
    }

    /**
     * 查询店铺状态
     */
    @GetMapping("/status")
    @ApiOperation(value = "查询店铺状态")
    public Result<Integer> getStatus()
    {
        Integer shop_status = (Integer)redisTemplate.opsForValue().get("SHOP_STATUS");
        return Result.success(shop_status);
    }
}
